package com.eric;

import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.utils.L1SpawnUtil;
import java.util.Timer;
import java.util.TimerTask;

public class RandomMobDeleteTimer extends TimerTask {
  private int _randomMobId;
  
  private L1NpcInstance[] _npc;
  
  public RandomMobDeleteTimer(int randomMobId, L1NpcInstance[] npc) {
    this._randomMobId = randomMobId;
    this._npc = npc;
  }
  
  public void run() {
    L1SpawnUtil.spawn(this._randomMobId);
    L1NpcInstance[] npc2;
    int length = (npc2 = this._npc).length;
    int i = 0;
    while (i < length) {
      L1NpcInstance npc = npc2[i];
      npc.deleteMe();
      i++;
    } 
    cancel();
  }
  
  public void begin() {
    Timer timer = new Timer();
    if (RandomMobTable.getInstance().getTimeSecondToDelete(this._randomMobId) > 0)
      timer.schedule(this, (RandomMobTable.getInstance().getTimeSecondToDelete(this._randomMobId) * 1000)); 
  }
}
